﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WowDotNetAPI.Models;
using Microsoft.Silverlight.Testing;

namespace WowDotNetAPI.Test
{
    [TestClass]
    public class AuthTests : SilverlightTest
    {
        private static WowExplorer explorer;

        [ClassInitialize]
        public static void ClassInit(TestContext context)
        {
            explorer = new WowExplorer(Region.US, Locale.en_US);
        }

        [TestMethod]
        [Asynchronous]
        public void FetchData_When_Authenticated()
        {
            bool done = false;
            WowExplorer authExplorer = new WowExplorer(Region.US, Locale.zh_TW, "", "");
            IEnumerable<Realm> realms = null;
            Realm realm = null;
            authExplorer.GetRealms(cb =>
                     {
                         realms = cb.Result ;
                         realm = realms.GetRealm("skullcrusher");
                         done = true;
                     });

            EnqueueConditional(() => done);   
            EnqueueCallback(() => Assert.IsNotNull(realm));
            EnqueueCallback(() => Assert.IsTrue(realm.Name == "Skullcrusher"));
            EnqueueCallback(() => Assert.IsTrue(realm.Type == RealmType.PVP));
            EnqueueCallback(() => Assert.IsTrue(realm.Slug == "skullcrusher"));
            EnqueueTestComplete();
        }
    }
}
